namespace System.Collections.Specialized
{
	[Serializable]
	class ReadOnlyArrayList : ICloneable, ICollection, IEnumerable, IList
	{
		// Fields
		private ArrayList _list;

		// Methods
		internal ReadOnlyArrayList(ArrayList list)
		{
			_list = list;
		}

		internal ReadOnlyArrayList(ICollection list)
		{
			_list = new ArrayList(list);
		}

		public int Add(object obj)
		{
			throw new NotSupportedException(SR.Get("NotSupported_ReadOnlyCollection"));
		}

		public void AddRange(ICollection c)
		{
			throw new NotSupportedException(SR.Get("NotSupported_ReadOnlyCollection"));
		}

		public int BinarySearch(int index, int count, object value, IComparer comparer)
		{
			return _list.BinarySearch(index, count, value, comparer);
		}

		public void Clear()
		{
			throw new NotSupportedException(SR.Get("NotSupported_ReadOnlyCollection"));
		}

		public object Clone()
		{
			var list = new ReadOnlyArrayList(_list);
			list._list = (ArrayList)_list.Clone();
			return list;
		}

		public bool Contains(object obj)
		{
			return _list.Contains(obj);
		}

		public void CopyTo(Array array, int index)
		{
			_list.CopyTo(array, index);
		}

		public void CopyTo(int index, Array array, int arrayIndex, int count)
		{
			_list.CopyTo(index, array, arrayIndex, count);
		}

		public IEnumerator GetEnumerator()
		{
			return _list.GetEnumerator();
		}

//		public IEnumerator GetEnumerator(int index, int count)
//		{
//			return _list.GetEnumerator(index, count);
//		}

//		public ArrayList GetRange(int index, int count)
//		{
//			if ((index < 0) || (count < 0))
//			{
//				throw new ArgumentOutOfRangeException((index < 0) ? "index" : "count", SR.Get("ArgumentOutOfRange_NeedNonNegNum"));
//			}
//			if ((Count - index) < count)
//			{
//				throw new ArgumentException(SR.Get("Argument_InvalidOffLen"));
//			}
//			return new ArrayList.Range(this, index, count);
//		}

		public int IndexOf(object value)
		{
			return _list.IndexOf(value);
		}

//		public int IndexOf(object value, int startIndex)
//		{
//			return _list.IndexOf(value, startIndex);
//		}

		public int IndexOf(object value, int startIndex, int count)
		{
			return _list.IndexOf(value, startIndex, count);
		}

		public void Insert(int index, object obj)
		{
			throw new NotSupportedException(SR.Get("NotSupported_ReadOnlyCollection"));
		}

		public void InsertRange(int index, ICollection c)
		{
			throw new NotSupportedException(SR.Get("NotSupported_ReadOnlyCollection"));
		}

//		public int LastIndexOf(object value)
//		{
//			return _list.LastIndexOf(value);
//		}
//
//		public int LastIndexOf(object value, int startIndex)
//		{
//			return _list.LastIndexOf(value, startIndex);
//		}
//
//		public int LastIndexOf(object value, int startIndex, int count)
//		{
//			return _list.LastIndexOf(value, startIndex, count);
//		}

		public void Remove(object value)
		{
			throw new NotSupportedException(SR.Get("NotSupported_ReadOnlyCollection"));
		}

		public void RemoveAt(int index)
		{
			throw new NotSupportedException(SR.Get("NotSupported_ReadOnlyCollection"));
		}

		public void RemoveRange(int index, int count)
		{
			throw new NotSupportedException(SR.Get("NotSupported_ReadOnlyCollection"));
		}

		public void Reverse(int index, int count)
		{
			throw new NotSupportedException(SR.Get("NotSupported_ReadOnlyCollection"));
		}

		public void SetRange(int index, ICollection c)
		{
			throw new NotSupportedException(SR.Get("NotSupported_ReadOnlyCollection"));
		}

		public void Sort(int index, int count, IComparer comparer)
		{
			throw new NotSupportedException(SR.Get("NotSupported_ReadOnlyCollection"));
		}

		public object[] ToArray()
		{
			return _list.ToArray();
		}

		public Array ToArray(Type type)
		{
			return _list.ToArray(type);
		}

		public void TrimToSize()
		{
			throw new NotSupportedException(SR.Get("NotSupported_ReadOnlyCollection"));
		}

		// Properties
		public int Capacity
		{
			get
			{
				return _list.Capacity;
			}
			set
			{
				throw new NotSupportedException(SR.Get("NotSupported_ReadOnlyCollection"));
			}
		}

		public int Count
		{
			get
			{
				return _list.Count;
			}
		}

		public bool IsFixedSize
		{
			get
			{
				return true;
			}
		}

		public bool IsReadOnly
		{
			get
			{
				return true;
			}
		}

		public bool IsSynchronized
		{
			get
			{
				return _list.IsSynchronized;
			}
		}

		public object this[int index]
		{
			get
			{
				return _list[index];
			}
			set
			{
				throw new NotSupportedException(SR.Get("NotSupported_ReadOnlyCollection"));
			}
		}

		public object SyncRoot
		{
			get
			{
				return _list.SyncRoot;
			}
		}
	}
}